<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/tagDeclare.jsp"%>
<%@include file="/headDeclare.jsp"%>
<%response.setHeader("cache-control","public"); %>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>字典列表</title>
	<style type="text/css"> 
	fieldset,table,tr,td {margin:0; padding:0;}
	td {padding:0 5px 0 10px;border:1px;}
	form label {font-weight:bold;}
	table{border-collapse: collapse;}
  </style>

  <script type="text/javascript">
	$(document).ready(function() { 
       	
        $("#btn_insert").click(function(){
            var queryString = $("#itemForm").formSerialize();
            queryString = encodeURIComponent(queryString);
            location.href = "<%=basePath%>item/insert.do?qs=" + queryString;
        });
        
        $("#btn_search").click(function(){
            $("#curPage").val(1);
            $("#itemForm").submit();
        });
        
        //批量删除
        $("#btn_batch_del").click(function(){
        	var queryString = $("#itemForm").formSerialize();
            queryString = encodeURIComponent(queryString);
        	var ids = null;
        	$("input[name='checkName']:checkbox:checked").each(function(){ 
        		if(ids == null)
        			ids = $(this).val();
        		else
        		    ids +=","+$(this).val() ;
        	}) ;
        	if(ids ==null)return;
        	if(ids == "")
        		{
        			alert("请选择");
        			return;
        		}
        	var url = "<%=basePath%>item/batchDelete.do?groupName=trade";
        	$.post(url,{ids:ids},function(data){
    			var responseJson = eval('(' + data + ')');
    			   if(responseJson.code==0)
    			   {
    					$("#error_label").text("错误信息：" + responseJson.message);
    	         		$("#p_error").show();
    	         		return;
    			   }else{
    					location.href = "<%=basePath%>item/list.do?groupName=trade";
    					$("#error_label").text("错误信息：" + responseJson.message);
    	         		$("#p_error").show();
    			   }
    		});
        	
        });
        
        $("#btn_change").click(function(){
            var page = parseInt($("#selectPage").val());
            var curPage = parseInt($("#curPage").val());
            if(curPage == page) return;
            $("#curPage").val(parseInt(page));
            $("#itemForm").submit();
        });
      
	}); 
	
	function del(id){
		var url = "<%=basePath%>item/delete.do";
		$.post(url,{id:id},function(data){
			var responseJson = eval('(' + data + ')');
			   if(responseJson.code==0)
			   {
					$("#error_label").text("错误信息：" + responseJson.message);
	         		$("#p_error").show();
	         		return;
			   }else{
					location.href = "<%=basePath%>item/list.do?groupName=trade";
			   }
		});
	}
	
  </script>
 </head>

 <body>
 
 <div style="width: 100%;">
  <div style="margin: auto;margin-top: 10px;">
      <form id="itemForm"  method="post" action="item/list.do">
        <table>
          <tr>
            <td><label for="name">行业名称:</label></td>
            <td><input type="text" name="itemValue" id="itemValue" value="${itemValue }" class="ldText" /></td>
            <td><input type="submit" id="btn_search" name="btn_search" value="查询" class="ldBtnBlue" /></td>
          </tr>
        </table>
        <input type="hidden" name="groupName" value="trade"/>
      </form>
  </div>
  <hr />
  <div>
  	<table border="0" cellspacing="0" cellpadding="0" width="100%" class="ld-datagrid">
	    <tr>
	      <th align="center" >
               <span style="cursor: pointer" onclick="changeStatus('all')">全</span>/<span style="cursor: pointer" onclick="changeStatus('invert')">反</span>
		  </th>
          <th style="text-align: center;">行业名称</th>
          <th style="text-align: center;">行业代号</th>
          <th style="text-align: center;">操作</th>
 	    </tr> 
	  	<c:forEach items="${list}" var="item" varStatus="status">
	  	<tr>
	  	  <td style="word-wrap: break-word; word-break:break-all;text-align: center;">
	  	  	<input name="checkName" type="checkbox" id="" value="${item.id }" />
	  	  </td>
	  	  <td style="word-wrap: break-word; word-break:break-all;text-align: center;">${item.itemValue }</td>
	  	  <td style="word-wrap: break-word; word-break:break-all;text-align: center;">${item.itemName }</td>
	  	  <td style="text-align: center;" >
  	  		<a href="item/update.do?id=${item.id }" class="ldBtnLink">修改</a>
  	  		<a href="javascript:del('${item.id }')" class="ldBtnLink">删除</a>
	  	  </td>
	  	</tr>
	  	</c:forEach>
  	</table>
  </div>
	<hr />
  <div>
	  <div style="float: left;">
	  	 <input type="button" id="btn_batch_del" name="btn_batch_del" value="批量删除" class="ldBtnGray" />
	  	 <input type="button" id="btn_insert" name="btn_insert" value="新增" class="ldBtnGray" />
	  </div>
	  <div style="float:right;"><p id = "p_error" style = "margin:10px 10px;"><label id="error_label" style="color:red;"></label></p></div>
  </div>
  
 </div>
 </body>
</html>

